package com.classtype.generic;

import java.util.ArrayList;
import java.util.List;

public class Test2<T> {

	private Class<T> type;

	public Test2(Class<T> type) {
		this.type = type;
	}

	public List<T> create(int count) {
		List<T> result = new ArrayList<T>();
		try {
			for (int i = 0; i < count; i++) {
				result.add(type.newInstance());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public static void main(String[] args) {
		Test2<Inner> t = new Test2<Inner>(Inner.class);
		System.out.println(t.create(15));
	}

}

class Inner {
	private static long counter;

	private final long id = counter++;

	public String toString() {
		return Long.toString(id);
	}
}
